<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var a1 = prompt('请输入你想买的水果');
      switch (a1) {
        case '苹果':
          alert('5块一斤');
          break;
        case '香蕉':
          alert('2块一斤');
          break;
        case '西瓜':
          alert('1.5一斤');
          break;
        default:
          alert('没有此水果');
      }
    </script>
  </body>
</html>
